<!--
 * Copyright TLR Team, Inc. All Rights Reserved.
-->
<div class="container-fluid" ng-if="userType === '0'">
    <!-- Page Heading -->
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header page-header2">
                设备管理
            </h1>
        </div>
    </div>
    <!-- /.row -->
    <div class="row fixed-buttons">
        <div>
            <div class="form-group fixed-button-panel">
                <button ng-click="onDeviceToolbarClick('add')" data-toggle="modal" data-target="#DeviceModal" type="button"
                        class="btn btn-default"><i
                        class="fa fa-plus-circle hella-icon-offset"></i>添加
                </button>
                <button ng-click="onDeviceToolbarClick('edit')" data-toggle="modal" data-target="#DeviceModal" type="button"
                        class="btn btn-default"><i class="fa fa-edit hella-icon-offset"></i>编辑
                </button>
                <button ng-if="subview === 'health'" ng-click="onDeviceToolbarClick('update_urgent_contact')" type="button"
                        class="btn btn-default"><i class="fa fa-edit hella-icon-offset"></i>更新紧急联系专员
                </button>
                <!--
                <button ng-click="onDeviceToolbarClick('addbinduser')" data-toggle="modal" data-target="#BindUserModal" type="button"
                        class="btn btn-default"><i class="fa fa-edit hella-icon-offset"></i>添加用户绑定
                </button> -->
                <button ng-click="deviceDeleteMode('device')" data-toggle="modal" data-target="#DelConfirmModal" type="button" class="btn btn-default"
                        style="margin-left: 50px;"><i class="fa fa-times-circle hella-icon-offset"></i>删除
                </button>
            </div>
        </div>
    </div>
    <div class="row" style="padding-top: 70px;">
        <div class="col-lg-12">
            <div>
                <!-- Nav tabs -->
                <ul class="nav nav-tabs">
                    <li role="presentation" ng-class="{'active':subview === 'purifier'}"><a href="#/dashboard-device/device/purifier">空气净化器</a></li>
                    <li role="presentation" ng-class="{'active':subview === 'health'}"><a href="#/dashboard-device/device/health" >健康仪</a></li>
                    <li role="presentation" ng-class="{'active':subview === 'measure'}"><a href="#/dashboard-device/device/measure">空气测量仪</a></li>
                    <li role="presentation" ng-class="{'active':subview === 'linkcard'}"><a href="#/dashboard-device/device/linkcard">服务车</a></li>
                </ul>
                <!-- Tab panes -->
                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane active" style="padding-top: 20px;">
                        <table class="table table-bordered" cellspacing="0" width="100%">
                            <thead class="tlr-table-header">
                                <tr>
                                    <th>选择</th>
                                    <th>编号</th>
                                    <th>设备标识</th>
                                    <th>设备备注名</th>
                                    <th ng-if="subview === 'linkcard'">设备绑定用户</th>
                                    <th>设备类型</th>
                                    <th>设备状态</th>
                                    <th>设备地址</th>
                                </tr>
                            </thead>
                            <tr ng-repeat-start="item in devices track by $index"
                                ng-click="onDeviceSelect(item)"
                                ng-class="{'tlr-table-row-selected':item.deviceid === device.deviceid }"
                                class="dashboard-table-tr">
                                <td><input type="checkbox" ng-checked="item.deviceid === device.deviceid" disabled></td>
                                <td>{{item.deviceid}}</td>
                                <td>{{item.devicemac}}</td>
                                <td>{{item.bindname}}</td>
                                <td ng-if="subview === 'linkcard'">{{item.binduser}}</td>
                                <td>{{DEVICE.type_labels[item.devicetype]}}</td>
                                <td ng-if='item.devicetype !== 2'>{{DEVICE.status_labels[item.status]}}</td>
                                <td ng-if='item.devicetype === 2'>{{DEVICE.car_statuses[item.status - 1].name}}</td>
                                <td>{{item.address}}</td>
                            </tr>
                            <tr ng-repeat-end ng-if="subview !== 'linkcard' && item.deviceid === device.deviceid">
                                <td></td>
                                <td colspan="6">
                                    <div style="width:100%;">
                                        <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                                            <div class="panel panel-default">
                                                <div class="panel-body">
                                                    <ul>
                                                        <li>
                                                            <span><b>绑定用户</b></span>
                                                            <ul>
                                                                <li ng-repeat="binduser in bindusers">
                                                                    <span>{{binduser.name}} | {{binduser.tel}} | {{binduser.address}}</span>
                                                                    <i ng-click="bindUserDeleteMode('binduser', binduser.id, item.devicemac)"
                                                                       class="glyphicon glyphicon-trash item-del-offset"
                                                                       data-toggle="modal" data-target="#DelConfirmModal"></i>
                                                                </li>
                                                                <li ng-if="!bindusers || bindusers.length === 0">
                                                                    无数据
                                                                </li>
                                                            </ul>
                                                        </li>
                                                        <li ng-if="subview === 'health'">
                                                            <span><b>天乐融紧急联系专员</b></span>
                                                            <ul>
                                                                <li ng-repeat="tlr_relation in tlr_relations">
                                                                    <span>{{tlr_relation.name}} | {{tlr_relation.mobile}}</span>
                                                                </li>
                                                                <li ng-if="!tlr_relations || tlr_relations.length === 0">
                                                                    无数据
                                                                </li>
                                                            </ul>
                                                        </li>
                                                        <li ng-if="subview === 'health'">
                                                            <span><b>紧急联系人</b></span>
                                                            <ul>
                                                                <li ng-repeat="relation in relations">
                                                                    <span>{{relation.name}} | {{relation.tel}}</span>
                                                                    <i ng-click="relationDeleteMode('delrelation', relation.id, item.devicemac)"
                                                                       class="glyphicon glyphicon-trash item-del-offset"
                                                                       data-toggle="modal" data-target="#DelConfirmModal"></i>
                                                                </li>
                                                                <li ng-if="!relations || relations.length === 0">
                                                                    无数据
                                                                </li>
                                                            </ul>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <ng-include src="'app/mvp/template/view/dashboard/form/device_form.html'"></ng-include>
    <ng-include src="'app/mvp/template/view/dashboard/form/del_confirm_form.html'"></ng-include>
    <!-- /.row -->
</div>